<script>
	import Vue from 'vue' ;
	import Host from './utils/api.js';
	 
	export default {
		globalData:{
			//用户openid
			openid: '',
			//用户id
			user_id: '',
			// 是否已登陆
			LoginStatus: false,
			vipStatus:'',
		},
		onLaunch: function() {
			let that = this;
			uni.login({
			  provider: 'weixin',
			  success: function (loginRes) {
				uni.request({
				    url: Host.ApiGetOpenid.url, //仅为示例，并非真实接口地址。
					method: 'GET',
				    data: {
				        code: loginRes.code,
				    },
				    success: (res) => {
						console.log(res.data.openid)
						that.globalData.openid = res.data.openid;
						uni.request({
						    url: Host.ApiGetuserInfo.url, //仅为示例，并非真实接口地址。
							method: 'GET',
						    data: {
						        openid: res.data.openid,
						    },
						    success: (res) => {
								if(res.data.result.user_is_vip == 2){
									that.globalData.vipStatus = 2//vip用户
									console.log('vip用户');
								}else{
									console.log('普通会员');
									that.globalData.vipStatus = 1;//put会员
								}
						    }
						});
				    }
				});
			  }
			});
		},
		onShow: function() {
			
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
